package com.example.yls.demoa;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;

public class MainActivity extends AppCompatActivity implements OnClickListener{
    private ProgressBar mProgressBar,mProgressBar2;
    private Button button;
    private Button button2;
    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        button =  findViewById(R.id.button);
        mProgressBar = findViewById(R.id.progressBar);
        mProgressBar2 = findViewById(R.id.progressBar2);
        imageView = findViewById(R.id.image_view);
        button.setOnClickListener((OnClickListener) this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.button:
//                旋转进度条
                if(mProgressBar.getVisibility() == View.GONE){
                    mProgressBar.setVisibility(View.VISIBLE);
                }else{
                    mProgressBar.setVisibility(View.GONE);
                }
//                直线进度条
            case R.id.button2:
                int progress = mProgressBar2.getProgress();
                progress = progress + 10;
                mProgressBar2.setProgress(progress);

                break;
            default:
                break;
        }
    }
}
